from django.shortcuts import render
from django.views import View



from goods.models import GoodsChannel, GoodsCategory

from .utils import get_categories
from .models import ContentCategory, Content

class IndexView(View):

    def get(self, request):

        #广告分类显示
        contents = {}

        contentCategory_qs = ContentCategory.objects.all()
        for category in contentCategory_qs:
            contents[category.key] = category.content_set.filter(status=True).order_by('sequence')




        #商品分类显示
        categories = get_categories()

        context = {
            'categories': categories,
            'contents': contents,


        }
        return render(request, 'index.html', context)
